<template>
  <div class="setnotice-content">
    <div class="setbox">
      <div class="jiushibox">
        <!-- <input class="tit" placeholder="请输入标题" v-model="tit"> -->
        <input class="settext" placeholder="请输入您想添加的公告,控制在20字" maxlength="20" v-model="content"/>
      </div>
    </div>
    <div class="addbtn" @click="Suk_savenotice">确定添加</div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      tit: "",
      content: ""
    };
  },
  beforeCreate: function() {
    //创建前
  },
  create: function() {
    //创建后
  },
  beforeMount: function() {
    //挂载前
  },
  mounted: function() {
    //挂载后
  },
  beforeUpdate: function() {
    //更新前
  },
  update: function() {
    //更新后
  },
  methods: {
    Suk_savenotice() {
      let that = this;
      that.$toast.loading({
        message: "加载中..."
      });
      var Sukdata = {
          userId:localStorage.getItem('userid'),
          content:that.content,
          title:that.tit,
          din_id:localStorage.getItem('myshopid')
      };
      console.log(Sukdata);
      that.axios
        .post(that.baseUrl + "/notice/setNotice", that.Qs.stringify(Sukdata), {
          headers: {
            "Content-Type": "application/x-www-form-urlencoded"
          }
        })
        .then(function(res) {
          if (res.request.status === 200) {
            if (res.data.meta.code == 200) {
              console.log(res.data);
              that.$toast.success({
                  message:'添加成功！'
              });
              that.$router.go(-1)
            } else if (res.data.meta.code == 501) {
            }
          }
        });
    }
  }
};
</script>
<style lang="scss" scoped>
.setnotice-content {
  font-size: 0.3rem;
  background: #f0f0f0;
  padding-bottom: 13rem;
}
.setbox {
  background: #fff;
  box-shadow: 0rem 0.05rem 0.2rem 0.1rem #e7e7e7;
  h1 {
    height: 1rem;
    line-height: 1rem;
    font-weight: 600;
    font-size: 0.5rem;
    border-bottom: 1px solid #f4f4f4;
  }
}
.jiushibox {
  width: 90%;
  margin: 0 auto;
}
.settext {
  margin-top: 0.1rem;
  width: 100%;
  height: 2rem;
  border: none;
}
.addbtn {
  background: #fda229;
  width: 80%;
  text-align: center;
  color: #fff;
  height: 1.1rem;
  line-height: 1.1rem;
  margin: 2rem auto;
  border-radius: 0.5rem;
  box-shadow: 0rem 0.05rem 0.2rem 0.1rem #e7e7e7;
}
.tit {
  border: none;
}
input{
  background: #fff;
}
textarea{
  background: #fff;
}
</style>